<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="../bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="../jquery/jquery-3.7.0.min.js"></script>
    <script src="../sidebars/sidebars.js"></script>
    <link href="../sidebars/sidebars.css" rel="stylesheet">
    <script src="../js/api/categoryApi.js"></script>
    <script src="../js/category.js"></script>
    <script src="../js/common.js"></script>
    <style>
        html, body {
            height: 100%;
            width: 100%;
        }
        main {
            height: 100%;
        }
    </style>
</head>
<body>
<main class="bg-body-secondary">
    <div class="card mx-2 my-2" style="height: 98%;">
        <div class="border-bottom py-2 bg-body-tertiary">
            <div class="d-flex">
                <div class="text-muted ms-3">
                    展示
                    <div class="mx-2 d-inline-block">
                        <select id="pageSize" class="form-select" aria-label="Default select example" onchange="show(1, this.value)">
                            <option value="5">5</option>
                            <option value="10">10</option>
                            <option value="15" selected>15</option>
                            <option value="20">20</option>
                        </select>
                    </div>
                    页数
                </div>
                <div class="ms-auto text-muted me-3">
                    <button class="card btn btn-outline-secondary d-inline-block mx-2" type="button" onclick="deleteCategory()"><span class="mx-2">删除</span></button>
                    <button type="button" class="align-middle btn btn-primary" data-bs-toggle="modal" data-bs-target="#itemModal" data-bs-type="add"><span class="align-middle me-2 px-0 py-0" style="font-weight: 1000; font-size: 20px">+</span><span class="align-middle">新增分类</span></button>
                </div>
            </div>
        </div>
        <div class="table-responsive" style="min-height: 180px; height: 90%">
            <table class="table card-table table-vcenter text-nowrap datatable">
                <thead>
                <tr>
                    <th class="w-1"><input id="checkHead" class="form-check-input m-0 align-middle" type="checkbox"
                                           aria-label="Select all invoices" onchange="setCheckAll(this)"></th>
                    <th class="w-1"><span class="d-flex justify-content-center">id</span>
                    </th>
                    <th><span class="d-flex justify-content-center">编码</span></th>
                    <th><span class="d-flex justify-content-center">名称</span></th>
                    <th><span class="d-flex justify-content-center">修改时间</span></th>
                    <th><span class="d-flex justify-content-center">创建时间</span></th>
                    <th><span class="d-flex justify-content-center"></span></th>
                </tr>
                </thead>
                <tbody id="tbody" style="height: 20%">
                <tr>
                    <td><input class="form-check-input m-0 align-middle" type="checkbox"
                               aria-label="Select invoice"></td>
                    <td><span class="d-flex justify-content-center">1</span></td>
                    <td><span class="d-flex justify-content-center">jackson</span></td>
                    <td><span class="d-flex justify-content-center">1243252341</span></td>
                    <td><span class="d-flex justify-content-center">2322-12-32</span></td>
                    <td><span class="d-flex justify-content-center">2322-12-32</span></td>
                    <td class="text-end">
                        <div class="d-flex justify-content-center">
                                <span class="dropdown">
                                  <button class="btn dropdown-toggle" data-bs-boundary="viewport"
                                          data-bs-toggle="dropdown">操作</button>
                                    <ul class="dropdown-menu dropdown-menu-start"
                                        style="min-width: 1px;">
                                        <li>
                                            <button class="dropdown-item" type="button">编辑</button>
                                        </li>
                                        <li>
                                            <button class="dropdown-item" type="button">删除</button>
                                        </li>
                                    </ul>
                                </span>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="card-footer d-flex align-items-center bg-body-tertiary">
            <p class="m-0 text-muted">展示 <span id="sumPage">16</span> 条数据中的 <span id="startPage">1</span> 到 <span
                    id="endPage">8</span> 条</p>
            <ul id="pageLink" class="pagination m-0 ms-auto">
            </ul>
            <p class="text-muted m-0 align-middle ms-3">前往<input class="card d-inline-block" style="width: 50px; text-align:center" type="text" onchange="pageItem(this)">页</p>
        </div>
    </div>
</main>
<div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h1 id="modalTitle" class="modal-title fs-5" id="exampleModalLabel">分类</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form id="categoryForm">
                    <div id="categoryCodeDiv" class="mb-3">
                        <input id="categoryId" style="display: none">
                        <label for="categoryCode" class="col-form-label">编码:</label>
                        <input type="text" class="form-control" id="categoryCode">
                    </div>
                    <div class="mb-3">
                        <label for="categoryName" class="col-form-label">名称:</label>
                        <input type="text" class="form-control" id="categoryName">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" onclick="document.querySelector('#categoryForm').reset()" class="btn btn-info">
                    清空
                </button>
                <button id="categoryModalClose" type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消
                </button>
                <button id="categoryModalSubmit" type="button" class="btn btn-primary">Send message</button>
            </div>
        </div>
    </div>
</div></body>
<script>
    $(function () {
        initCategory();
    })
</script>
</html>